import { defineStore } from 'pinia'
import { computed, ref } from 'vue'
import zhCn from 'element-plus/dist/locale/zh-cn.mjs'
import en from 'element-plus/dist/locale/en.mjs'

export const useGobalStore = defineStore('global', () => {
    // language 的值有两个 zh-cn english
    const language = ref('zh-cn')
    //更改语言
    const changeLanguage = (val: string) => {
        language.value = val
    }
    const locale = computed<string>(() => (language.value === 'zh-cn' ? zhCn : en))
    return {
        language, locale, changeLanguage
    }
})